#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time: 2019/4/13  18:03
# @Author: 余浪人
# @email: yulangren520@gmail.com

from wtforms import Form, StringField, validators, TextAreaField, BooleanField, DateField, IntegerField,RadioField


class System_Form(Form):
    web_name = StringField(label='站点名称', render_kw={"class": "layui-input", "placeholder": "请输入站点名称","style":"width:30%;"})
    web_domain = StringField(label='网站域名', render_kw={"class": "layui-input", "placeholder": "http://","style":"width:40%;"})
    web_logo = StringField(label='网站LOGO', render_kw={"class": "layui-input", "style": "width:40%;display: inline-block;","readonly":"readonly"})
    web_QrCode = StringField(label='网站二维码', render_kw={"class": "layui-input", "style": "width:40%;display: inline-block;","readonly":"readonly"})
    web_record = StringField(label='备案号',
                             render_kw={"class": "layui-input", "placeholder": "请输入备案号", "style": "width:40%;"})
    web_key = StringField(label='站点关键词', render_kw={"class": "layui-input", "placeholder": "请输入关键词","style":"width:60%;"})
    web_description = TextAreaField(label='站点描述',render_kw={"placeholder":"请输入描述内容","class":"layui-textarea","style":"width:60%;"})
    web_all_key = StringField(label='全局关键词', render_kw={"class": "layui-input", "placeholder": "请输入全局关键词","style":"width:60%;"})
    web_topBar = StringField(label='顶部描述',validators=[validators.Length(0,255,'顶部描述长度超出限制!')], render_kw={"class": "layui-input","style":"width:60%;"})
    web_stat = TextAreaField(label='统计代码',render_kw={"placeholder":"请输入统计代码","class":"layui-textarea","style":"width:60%;"})
    # web_company = StringField(label='公司/单位/团体名称', render_kw={"class": "layui-input", "placeholder": "公司/单位/团体名称","style":"width:40%;"})
    # web_contact_adders = StringField(label='联系地址', render_kw={"class": "layui-input", "placeholder": "联系地址","style":"width:40%;"})
    # web_contact_tel = StringField(label='联系电话', render_kw={"class": "layui-input", "placeholder": "联系电话","style":"width:40%;"})
    web_contact_qq = StringField(label='联系QQ', render_kw={"class": "layui-input", "placeholder": "请输入QQ","style":"width:40%;"})
    web_contact_email = StringField(label='联系邮箱',
                        render_kw={"class": "layui-input", "placeholder": "请输入邮箱地址", "lay-verify": "email","style":"width:40%;"})
    # web_message = TextAreaField(label='留言提示',render_kw={"placeholder":"请输入留言提示内容","class":"layui-textarea","style":"width:60%;"})
    web_on_off=BooleanField('站点开关',render_kw={"lay-skin":"switch","style": "width: 50px;"})


class Ad_Form(Form):
    ad_name=StringField(label='广告名称',validators=[validators.DataRequired(message="广告名称不可为空")], render_kw={"class": "layui-input", "placeholder": "请输入广告名称","lay-verify":"title","style":"width: 200px;"})
    ad_end_date = DateField(label='到期时间',
                            render_kw={"class": "layui-input", "lay-verify": "date", "style": "width: 200px;"})
    ad_code = TextAreaField(label='广告代码',render_kw={"class":"layui-textarea","style": "width: 500px;"})
    ad_description = TextAreaField(label='广告描述',render_kw={"class":"layui-textarea","rows": "2","style":"min-height: 50px;width: 700px;"})
    status= BooleanField(label='状态',render_kw={"lay-skin":"switch","lay-text":"开启|关闭","style": "width: 50px;"})


class Blogroll_Form(Form):
    link_name = StringField(label='链接名称', validators=[validators.DataRequired(message='链接名不可为空')],
                            render_kw={"class": "layui-input", "lay-verify": "required","style": "width: 60%;"})
    link_url = StringField(label='链接地址',default='http://',validators=[validators.DataRequired('链接地址不可为空!'),validators.URL(message='地址格式有误!')],
                           render_kw={"class": "layui-input", "lay-verify": "url|required","style": "width: 80%;"})
    color = StringField(label='链接颜色',default='#292929', render_kw={"class": "layui-input","style": "width: 20%;"})
    link_sort = StringField(label='排序',validators=[validators.Regexp(r'^\d*$',message='排序格式为整数!')],default=0, render_kw={"class": "layui-input","style": "width: 50px;"})
    isbold = RadioField(label='链接字体',default=1,choices=[(1,'正常显示'),(2,'加粗显示')],coerce=int)
    status = BooleanField(label='状态',render_kw={"lay-skin":"switch","lay-text":"开启|关闭","style": "width: 50px;"})


class Share_Form(Form):
    share_detail = TextAreaField(label='详情分享',render_kw={"class":"layui-textarea","style":"width: 60%;"})
    share_all = TextAreaField(label='整站分享', render_kw={"class": "layui-textarea","style":"width: 60%;"})

class Api_Form(Form):
    api_key = TextAreaField(label='API-Key',render_kw={"class":"layui-textarea","placeholder": "请输入自定义key","style":"width: 60%;"})
    api_ak = TextAreaField(label='API-AK', render_kw={"class": "layui-textarea","style":"width: 60%;"})

class Discuss_Form(Form):
    discuss_code = TextAreaField(label='评论代码', render_kw={"class": "layui-textarea", "style": "width: 60%;"})

class Accredit_Form(Form):
    domain = StringField('授权域名',validators=[validators.URL(message='域名格式错误!')],
                         render_kw={"class": "layui-input", "placeholder": "例: tlcms.com","style":"width:40%;"})
    accredit_code = TextAreaField('授权密钥',
                         render_kw={"class": "layui-textarea", "style": "width:40%;"})